package com.peng.controller;

import com.github.pagehelper.PageInfo;
import com.peng.Repo.PageStatic;
import com.peng.pojo.Group;
import com.peng.service.GroupChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Date;

@RestController
public class GroupChatController {
    @Autowired
    private GroupChatService groupChatService;

    @GetMapping("/admin/getAllGroup")
    public PageInfo<Group> getAllGroup(@Nullable @RequestParam(name = "name") String name,
                                       @Nullable @RequestParam(name = "time") Date time,
                                       @RequestParam(name = "page", defaultValue = PageStatic.page) int page,
                                       @RequestParam(name = "size", defaultValue = PageStatic.size) int size) {
        return groupChatService.selectAllGroup(name, time, page, size);
    }

    @GetMapping("/admin/updateGroupStatus")
    public boolean updateGroupStatus(@RequestParam(name = "status", defaultValue = "1") int status,
                                     @RequestParam(name = "id") Integer... id) {
        return groupChatService.updateGroupStatus(status, id);
    }
}
